package com.example.blog.enums;

import org.springframework.util.StringUtils;

public enum Role {
    ADMIN("10000","管理员"),
    USER("10001","管理员"),
    GUEST("10002","管理员");
    private String code;

    private String description;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    private Role(String code, String description) {
        this.code = code;
        this.description = description;
    }
    public static Role get(String code) {
        if (StringUtils.hasLength(String.valueOf(code))) {
            for (Role element : Role.values()) {
                if (element.getCode().equals(code)) {
                    return element;
                }
            }
        }
        return null;
    }
}
